<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 供应商搜索 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="类型" prop="client_contact"> 供应商 </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商分类" prop="client_class">
              <el-select style='width:100%' v-model="s_search.client_class">
                <el-option label="组织" value="组织" />
                <el-option label="个人" value="个人" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="client_name">
              <el-input v-model="s_search.client_name" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="网站地址" prop="client_net">
              <el-input v-model="s_search.client_net" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="信息来源" prop="client_origin">
              <el-select style='width:100%' v-model="s_search.client_origin">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in clientorigin" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="地区" prop="address_nation">
              <el-select v-model="s_search.address_nation">
                <el-option label="中国" value="中国" />
                <el-option label="海外" value="海外" />
              </el-select> 省 <el-select v-model="s_search.address_province" @change="list_s_province">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_province" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select> 市 <el-select v-model="s_search.address_city" @change="list_s_city">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_city" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select> 县 <el-select v-model="s_search.address_town">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_district" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="('')" type='success' size="mini"><i class='fa fa-check'></i>搜索</el-button>
      <el-button @click="gotoPage('/psi/supplychainmana/SupplierSearch?&execute=Search&searchClear=true'+vueparams+'')" type='primary' size="mini">重置</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'SupplierSearch',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_search: {
          client_contact: null,
          client_class: null,
          client_name: null,
          client_net: null,
          client_origin: null,
          address_nation: null,
          address_province: null,
          address_city: null,
          address_town: null,
        },
        clientorigin: [],
        s_province: [],
        s_city: [],
        s_district: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/supplierSearch?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      list_s_province(value) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/ajaxList?' + this.vueparams,
          params: {
            htmltable: '',
            cfield_name: "address_city",
            address_province: value
          }
        }).then(data => {
          this.$set(this.s_search, 'address_city', '');
          this.s_city = data['address_city'];
        })
      },
      list_s_city(value) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/ajaxList?' + this.vueparams,
          params: {
            htmltable: '',
            cfield_name: "address_town",
            address_city: value
          }
        }).then(data => {
          this.$set(this.s_search, 'address_town', '');
          this.s_district = data['address_town'];
        })
      },
    },
  }
</script>
